<?php
class sfVideoValidatedFile extends sfValidatedFile
{
  public function save($file = null, $fileMode = 0666, $create = true, $dirMode = 0777)
  {
     //$this->path=sfConfig::get('sf_upload_dir')."/material/gallery";
     
    $file_name = parent::save($file, $fileMode, $create, $dirMode);
    
    //Обжим
    $this->generateThumbnail ( $file_name );
    
    /////
    
    return $file_name;
  }
  
public function generateThumbnail($value) 

	{
		@unlink($uploadDir . '/users/video/thumbnail/' . $value);
		$uploadDir = sfConfig::get ( 'sf_upload_dir' );
		
		
		
		$str = 'ffmpeg -i '.$uploadDir . '/users/video/'.$value.' -ar 22050 -ab 32 -f flv -s 320x240 '.$uploadDir . '/users/video/'.$value.'.flv';
		passthru($str);
		
		$str = 'ffmpeg -i '.$uploadDir . '/users/video/'.$value.'.flv -an -ss 00:00:01 -t 00:00:01 -r 1 -y -s 320x240 -f image2 '.$uploadDir.'/users/video/thumbnail/'.$value.'.jpeg';
	    passthru($str);
	  
		//$thumbnail = new sfThumbnail ( 120, 120 );
		//$thumbnail->loadFile ( $uploadDir . '/users/gallery/' . $value );
		//$thumbnail->save ( $uploadDir . '/users/gallery/thumbnail/' . $value );
	
	}
	
	
	
}